<template>
	<view>
		<view class="page">
			<comp-common v-bind="{data:data}" @getUserInfo="getUserInfo" @myLogin="myLogin" @getPhoneNumber="getPhoneNumber" @hideGetCoupon="hideGetCoupon" @closeCouponBox="closeCouponBox" @navigatorClick="navigatorClick"></comp-common>
			<comp-header v-bind="{data:data}" @relevanceError="relevanceError" @relevanceSuccess="relevanceSuccess"></comp-header>
			<view class="body after-navber">
				<view class="new-body">
            <view class="title px-24">{{data.title}}</view>
            <view class="flex-row info fs-sm px-24">
                <view class="flex-grow-1">{{data.addtime}}</view>
                <view class="flex-grow-0">{{data.read_count}}</view>
            </view>
            <view class="content">
							<wx-parse :myNodes="data.content.nodes"></wx-parse>
            </view>
        </view>
        <cover-view class="bar">
            <cover-view class="flex-row">
                <cover-view class="flex-grow-1 flex-x-center">
                    <cover-view @tap="favoriteClick" class="btn fs-sm" data-action="0" v-if="data.is_favorite==1">
                        <cover-image class="icon" :src="data.__wxapp_img.topic.love_active.url"></cover-image>
                        <cover-view>已收藏</cover-view>
                    </cover-view>
                    <cover-view @tap="favoriteClick" class="btn fs-sm" data-action="1" v-else>
                        <cover-image class="icon" :src="data.__wxapp_img.topic.love.url"></cover-image>
                        <cover-view>收藏</cover-view>
                    </cover-view>
                </cover-view>
                <cover-view class="flex-grow-1 flex-x-center">
                    <cover-view @tap="showShareModal" class="btn fs-sm">
                        <cover-image class="icon" :src="data.__wxapp_img.topic.share.url"></cover-image>
                        <cover-view>分享</cover-view>
                    </cover-view>
                </cover-view>
            </cover-view>
        </cover-view>
			</view>
			<save-qrcode v-bind="{data:data}" @qrcodeClick="qrcodeClick" @saveQrcode="saveQrcode" @qrcodeClose="qrcodeClose" @getGoodsQrcode="getGoodsQrcode" @shareModalClose="shareModalClose" @onShareWebMessage="onShareWebMessage"></save-qrcode>
			<comp-footer v-bind="{data:data}"></comp-footer>
			<comp-quick-navigation v-bind="{data:data}" @cutover="cutover" @map_power="map_power" @to_dial="to_dial" @openWxapp="openWxapp"></comp-quick-navigation>
		</view>
	</view>
</template>

<script>var myVue = {};
	import saveQrcode from '../../components/save_qrcode/save_qrcode.vue'
	var e = require('../../wxParse/wxParse.js')
	export default {
		components:{saveQrcode},
		data() {
			return {
				data: {
					content: {}
				},
			};
		},
		onLoad: function(t) {myVue = this;
        myVue.getApp.page.onLoad(this, t);
        var o = this;
        if ("undefined" == typeof my) {
            var a = decodeURIComponent(t.scene);
            if (void 0 !== a) {
                var i = myVue.getApp.helper.scene_decode(a);
                i.uid && i.gid && (t.id = i.gid);
            }
        } else if (null !== myVue.getApp.query) {
            var c = app.query;
            myVue.getApp.query = null, t.id = c.gid;
        }
        myVue.getApp.request({
            url: myVue.getApp.api.default.topic,
            data: {
                id: t.id
            },
            success: function(t) {
                0 == t.code ? (o.setData(t.data),e.wxParse("content", "html", t.data.content, o)) : o.getApp.core.showModal({
                    title: "提示",
                    content: t.msg,
                    showCancel: !1,
                    success: function(e) {
                        e.confirm && o.getApp.core.redirectTo({
                            url: "/pages/index/index"
                        });
                    }
                }),console.log(o.data);
            }
        });
    },
		onShow: function() {
        myVue.getApp.page.onShow(this);
    },
    onShareAppMessage: function() {
        myVue.getApp.page.onShareAppMessage(this);
        var e = myVue.getApp.getUser(), t = this.data.id;
        return {
            title: this.data.title,
            path: "/pages/topic/topic?id=" + t + "&user_id=" + e.id
        };
    },
		methods: {
			wxParseTagATap: function(e) {
        if (e.currentTarget.dataset.goods) {
            var t = e.currentTarget.dataset.src || !1;
            if (!t) return;
            myVue.getApp.core.navigateTo({
                url: t
            });
        }
    },
    quickNavigation: function() {
        this.setData({
            quick_icon: !this.data.quick_icon
        });
				//#ifndef H5
        var e = myVue.getApp.core.createAnimation({
            duration: 300,
            timingFunction: "ease-out"
        });
        this.data.quick_icon ? e.opacity(0).step() : e.translateY(-55).opacity(1).step(), 
        this.setData({
            animationPlus: e.export()
        });
				//#endif
    },
    favoriteClick: function(e) {
        var t = this, o = e.currentTarget.dataset.action;
        myVue.getApp.request({
            url: myVue.getApp.api.user.topic_favorite,
            data: {
                topic_id: t.data.id,
                action: o
            },
            success: function(e) {
                t.getApp.core.showToast({
                    title: e.msg
                }), 0 == e.code && t.setData({
                    is_favorite: o
                });
            }
        });
    },
		showShareModal: function() {
        this.setData({
            share_modal_active: "active"
        });
    },
    shareModalClose: function() {
        this.setData({
            share_modal_active: ""
        });
    },
    getGoodsQrcode: function() {
        var e = this;
        if (e.setData({
            qrcode_active: "active",
            share_modal_active: ""
        }), e.data.goods_qrcode) return !0;
        myVue.getApp.request({
            url: myVue.getApp.api.default.topic_qrcode,
            data: {
                goods_id: e.data.id
            },
            success: function(t) {
                0 == t.code && e.setData({
                    goods_qrcode: t.data.pic_url
                }), 1 == t.code && (e.goodsQrcodeClose(), e.getApp.core.showModal({
                    title: "提示",
                    content: t.msg,
                    showCancel: !1,
                    success: function(e) {
                        e.confirm;
                    }
                }));
            }
        });
    },
    qrcodeClick: function(e) {
        var t = e.currentTarget.dataset.src;
        myVue.getApp.core.previewImage({
            urls: [ t ]
        });
    },
    qrcodeClose: function() {
        this.setData({
            qrcode_active: ""
        });
    },
    goodsQrcodeClose: function() {
        this.setData({
            goods_qrcode_active: "",
            no_scroll: !1
        });
    },
    saveQrcode: function() {
        var e = this;
        myVue.getApp.core.saveImageToPhotosAlbum ? (myVue.getApp.core.showLoading({
            title: "正在保存图片",
            mask: !1
        }), myVue.getApp.core.downloadFile({
            url: e.data.goods_qrcode,
            success: function(e) {
                myVue.getApp.core.showLoading({
                    title: "正在保存图片",
                    mask: !1
                }), myVue.getApp.core.saveImageToPhotosAlbum({
                    filePath: e.tempFilePath,
                    success: function() {
                        myVue.getApp.core.showModal({
                            title: "提示",
                            content: "专题海报保存成功",
                            showCancel: !1
                        });
                    },
                    fail: function(e) {
                        myVue.getApp.core.showModal({
                            title: "图片保存失败",
                            content: e.errMsg,
                            showCancel: !1
                        });
                    },
                    complete: function(e) {
                        myVue.getApp.core.hideLoading();
                    }
                });
            },
            fail: function(t) {
                myVue.getApp.core.showModal({
                    title: "图片下载失败",
                    content: t.errMsg + ";" + e.data.goods_qrcode,
                    showCancel: !1
                });
            },
            complete: function(e) {
                myVue.getApp.core.hideLoading();
            }
        })) : myVue.getApp.core.showModal({
            title: "提示",
            content: "当前版本过低，无法使用该功能，请升级到最新版本后重试。",
            showCancel: !1
        });
    },
    onShareWebMessage: function() {
        myVue.getApp.page.onShareAppMessage(this);
        var e = myVue.getApp.getUser(), t = this.data.id;
				this.$webShare({
					title: this.data.title,
					path: "/pages/topic/topic?id=" + t + "&user_id=" + e.id
				}).then(function() {
					
				})
    },
		},
	}
</script>

<style scoped>

.new-body {
    background: #fff;
    padding: 32upx 0 110upx;
    overflow-x: hidden;
    border-top: 1upx solid #e3e3e3;
}

.new-body .title {
    font-weight: bold;
    margin-bottom: 42upx;
}

.new-body .info {
    color: #888;
    margin-bottom: 34upx;
}

.bar {
    position: fixed;
    z-index: 10;
    bottom: var(--window-bottom);
    left: 0;
    width: 100%;
    background: #fff;
    border-top: 1upx solid #e3e3e3;
}

.bar .btn {
    color: #555;
    text-align: center;
    padding: 10upx 30upx;
    display: inline-block;
    background: none;
    line-height: inherit;
}

.bar .btn:after {
    display: none;
}

.bar .btn cover-image,.bar .btn image {
    width: 42upx;
    height: 42upx;
    display: block;
    margin: 0 auto 10upx;
}

.page /deep/ .wxParse-p {
    padding-left: 0;
    padding-right: 0;
}

.page /deep/ .goods-link {
    overflow: hidden;
    height: 220upx!important;
    position: relative;
    margin-bottom: 10upx;
}

.page /deep/ .goods-link image {
    width: 184upx!important;
    height: 184upx!important;
    background: #fff;
    top: 16upx;
    left: 16upx;
    position: absolute;
    display: block;
}

.page /deep/ .goods-info {
    padding: 32upx 24upx 24upx 232upx!important;
    height: 100%;
}

.page /deep/ .goods-name {
    -webkit-line-clamp: 2;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 16upx;
}

.page /deep/ .wxParse-p image {
    margin-left: 0;
    margin-right: 0;
}
</style>
